package com.mutouren.common.orm;

import java.util.List;

public abstract class BaseDaoImpl<T> implements BaseDao<T>  {
	
	@Override
	public abstract String getNameSpace(String statement);
	
	@Override
	public abstract String getCfgName();
	
	@Override
	public T get(Object paramId) {
		return IbatisHelper.selectOne(getNameSpace("get"), paramId, getCfgName());
	}
	
	@Override
	public List<T> select(Object parameter) {
		return IbatisHelper.selectList(getNameSpace("select"), parameter, getCfgName());
	}	

	@Override
	public void insert(T paramT) {
		IbatisHelper.insert(getNameSpace("insert"), paramT, getCfgName());
	}

	@Override
	public int update(T paramT) {
		return IbatisHelper.update(getNameSpace("update"), paramT, getCfgName());
	}
	
	@Override
	public T get(Object paramId, Transcation trans) {
		return IbatisHelper.selectOne(getNameSpace("get"), paramId, (IbatisTrans)trans);
	}
	
	@Override
	public List<T> select(Object parameter, Transcation trans) {
		return IbatisHelper.selectList(getNameSpace("select"), parameter, (IbatisTrans)trans);
	}	

	@Override
	public void insert(T paramT, Transcation trans) {
		IbatisHelper.insert(getNameSpace("insert"), paramT, (IbatisTrans)trans);
	}

	@Override
	public int update(T paramT, Transcation trans) {
		return IbatisHelper.update(getNameSpace("update"), paramT, (IbatisTrans)trans);
	}	

}
